package lab1;

import java.util.Iterator;


public class ClientBrain implements Runnable{

	private Server server;
	
	ClientBrain(Server s){
		this.server = s;
	}//ClientBrain
	
	public void run(){
		while(true){
			synchronized (server.clientMap){
				for (Iterator<String> it = server.clientMap.keySet().iterator(); it.hasNext();) {
				    String c = it.next();
				//for(String c : server.clientMap.keySet()){
					if(System.currentTimeMillis() - server.clientMap.get(c) > server.holdTime ){
						System.out.println("Unregistering Client with ID: "+c);
						server.logFiller(" Client " + c + " wird gel�scht");
						it.remove();
//						server.clientMap.remove(c);
					}//if   
				}//for
			}//synchronized
		}//while	
	}//run
}//ClientBrain
